package com.tangsm.api.demo.service;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * redis生产者
 */
@Service
public class RedisProducerImpl {
 
    @Autowired
    private RedisTemplate redisTemplate;

    public void produce(String key, String msg) {
        Map<String, String> map = new HashMap<>();
        map.put("fileId", msg);
        redisTemplate.opsForList().leftPush(key, map);
        System.out.println("redis生产者："+ JSON.toJSONString(map));
    }
}